from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import urlfetch


class ProxyPage(webapp.RequestHandler):
    
    def get(self):
    	result = urlfetch.fetch(url="http://ec2-67-202-8-193.compute-1.amazonaws.com:8800" + self.request.path_qs)
        self.response.out.write(result.content)

    def post(self):
        self.response.headers.add_header("Access-Control-Allow-Origin", "*")
        result = urlfetch.fetch(url="http://ec2-67-202-8-193.compute-1.amazonaws.com:8800" + self.request.path_qs,
                                payload=self.request.body,
                                method=urlfetch.POST,
                                validate_certificate=False)
        
        self.response.out.write(result.content)


application = webapp.WSGIApplication(
    [('/.*', ProxyPage)],
    debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
